#include "mythread.h"
#include <QCoreApplication>
#include <QDebug>
 
MyThread::MyThread() {}
 
 
void MyThread::run() {
    doWork(); //执行线程任务
    exec(); //进入线程循环
}
 
 
void MyThread::doWork() {
    if(QThread::currentThread() == QCoreApplication::instance()->thread())
        qDebug() << "当前任务运行在主线程:" << QThread::currentThread();
    else
        qDebug() << "当前任务运行在新线程:" << QThread::currentThread();
}
